# -*- coding: utf-8 -*-
# @Time : 2022/4/9 20:57
# @Author : Liuqing
# @File : 19_合并两个列表到字典.py
# @Software : PyCharm
def list2dictionary(k, v):
    return dict(zip(k, v))


if __name__ == '__main__':
    k = ['a', 'b', 'c']
    v = [2, 3, 4]
    print(list2dictionary(k, v))     # 内置函数法zip()

    print({x: y for x, y in zip(k, v)})    # 去除dict的隐式转换

    # for循环
    new_dict = dict()
    for k, v in zip(k, v):
        if k not in new_dict.keys():
            new_dict[k] = v
    print(new_dict)
